package dp.test122;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/7/23 9:11
 */
public class Solution1 {

    public int maxProfit(int[] prices) {
        int ans = 0, cur = 0;
        for (int i = 0; i < prices.length - 1; i++) {
            cur = prices[i + 1] - prices[i];
            if (cur > 0) ans += cur;
        }
        return ans;
    }
}
